<?php
declare(strict_types=1);

namespace Service\Consumer\YunCangConsumer\Router;
use Service\BaseService;
use App\Model\BbcModel\Goods;
use Service\Code\Normal;

/**
 * 产地变更
 * @author chenshubo
 */
class countryChange extends BaseService
{
    /**
     * 接收消费数据
     * @param int $sid
     * @param int $cid
     * @param array $data
     * @param string $messageId
     * @param int $IsFinished
     */
    public function consumer(int $sid,int $cid,array $data,string $messageId,int $IsFinished)
    {
        try
        {
            $before = $data['before'];
            $after  = $data['after'];
            Goods::instance()->where('origin',$before['CountryName'])->where('cid',$cid)->update(['origin'=>$after['CountryName']]);
            return Normal::returnCode(Normal::SUC,"处理完成");
        } catch ( \Throwable $th ) {
            $error = [
                'error'         => $th->getMessage(),
                'errorFile'     => $th->getFile(),
                'errorLine'     => $th->getLine(),
            ];
            $_class_name = __CLASS__;
            return Normal::returnCode(Normal::FAIL,"{$_class_name}消费处理处理异常【{$error['error']}】",$error);
        }
    }
}